#ifndef VOLUMECONTROL_H
#define VOLUMECONTROL_H
#include "sumHeader.h"

class Square:public QWidget
{
    Q_OBJECT
public:
    Square(QWidget *parent = nullptr);
   ~Square();
    const constexpr static int Width = 32;
    const constexpr static int Height = 48;


signals:
    void sendVolumeControlVolumeLevel(int x);
private:
    void paintEvent(QPaintEvent *event) override;
    void mouseMoveEvent(QMouseEvent *event) override;
    void mousePressEvent(QMouseEvent *event) override;
    void mouseReleaseEvent(QMouseEvent *event) override;
private:
    QPoint _lastMousePos;
};


class VolumeControl:public QWidget
{
    Q_OBJECT
public:
    VolumeControl(QWidget *parent = nullptr);
    ~VolumeControl();
    void loadLayOut();
    double GetVolumeRatio()
    {
        return _volumeRatio;
    }
    const constexpr static int VolumeWidth = 414;
    const constexpr static int VolumeHeight = 50;

    const constexpr static int VolumeStartX = 38;
    const constexpr static int VolumeStartY = 15;
signals:
    void changeVolume(double);
private:
    void paintEvent(QPaintEvent *event) override;
private slots:
    void acceptVolumeLevel(int x);
private:
    Square *_mark;
    int _volumeSize;
    double _volumeRatio;//目前音量大小占总大小的比例
};

#endif // VOLUMECONTROL_H
